import { Injectable } from '@angular/core';
import {adSystemApiUrl} from '../../../../config/api';
import {HttpService} from '../http.service';

@Injectable()
export class HomeConfigService {

  constructor(private httpService: HttpService) { }

  getHomeConfigList() {
    const url = adSystemApiUrl + '/v1/admin/site_setting/list';
    return this.httpService.httpGetAuth(url).map(data => data);
  }

  getHomeConfigDetail(id: number) {
    const url = adSystemApiUrl + '/v1/admin/site_setting/detail?id=' + id;
    return this.httpService.httpGetAuth(url).map(data => data);
  }

  addHomeConfig(data: any) {
    const url = adSystemApiUrl + '/v1/admin/site_setting/add';
    return this.httpService.httpPostAuth(url,data).map(data => data);
  }

  editHomeConfig(data: any) {
    const url = adSystemApiUrl + '/v1/admin/site_setting/edit';
    return this.httpService.httpPostAuth(url,data).map(data => data);
  }

  delHomeConfig(id: number) {
    const url = `${adSystemApiUrl}/v1/admin/site_setting/del?id=${id}`;
    return this.httpService.httpPostAuth(url, {}).map(data => data);
  }
}
